package io.vov.vitamio.activity;

import io.vov.vitamio.R;
import io.vov.vitamio.VideoPlayer;
import io.vov.vitamio.widget.BaseMediaController;
import io.vov.vitamio.widget.ServiceVideoView;
import android.app.Activity;
import android.os.Bundle;

import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout.LayoutParams;
import android.view.View.OnClickListener;

public class MainActivity extends Activity implements OnClickListener {

	private ServiceVideoView mVideoView;
	private ServiceVideoView mVideoView2;
	private VideoPlayer mVideoPlayer;
	private FrameLayout fl_video;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		mVideoView = (ServiceVideoView) findViewById(R.id.video);
		mVideoView2 = (ServiceVideoView) findViewById(R.id.video2);
		fl_video=(FrameLayout)findViewById(R.id.fl_video);
		final BaseMediaController mc = (BaseMediaController) findViewById(R.id.mc);
		
		WindowManager wm = this.getWindowManager();
		 
	     int width = wm.getDefaultDisplay().getWidth();
	     int height = wm.getDefaultDisplay().getHeight();
	     
	     LayoutParams params=new LayoutParams(width, width*5/8);
	     fl_video.setLayoutParams(params);

		mVideoPlayer = new VideoPlayer(this, mVideoView);
		
		mVideoPlayer
				.setVideoPath("http://7xsylc.com2.z0.glb.qiniucdn.com/1.mp4");
		mVideoPlayer.setMeidaController(mc);
		mc.setAutoPlay(false);
		
		
	}

	@Override
	public void onClick(View v) {
		switchVideo();
	}

	int index = 2;

	private void switchVideo() {
		Log.d("video", "ȫ����Ƶ");
	}

	@Override
	protected void onDestroy() {
		mVideoPlayer.onDestory();
		super.onDestroy();
	}

}
